﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using model;
using System.Data;
using System.Data.SqlClient;

namespace dao
{
    public class LoaibaivietDao:BaseDao
    {
        public List<Loaibaiviet> GetListAllLoaiBaiviet()
        {
            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "sp_loaibaiviet_SelectAll";
            sqlCmd.Parameters.Clear();
            sqlCmd.Connection.Open();

            using (SqlDataReader dr = sqlCmd.ExecuteReader())
            {
                List<Loaibaiviet> glstLoaiBaiviet = new List<Loaibaiviet>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Loaibaiviet bv = new Loaibaiviet();
                        bv.ID = Convert.ToInt64(dr["ID"]);
                        bv.Maloaibai = Convert.ToString(dr["Maloai"]);
                        bv.Tenloaibai = Convert.ToString(dr["Tenloai"]);
                       
                        glstLoaiBaiviet.Add(bv);
                    }
                    dr.Close();
                    sqlCmd.Connection.Close();
                }
                return glstLoaiBaiviet;
            }
        }
    }
}
